package tt.dz.egobus.servicemanager.core.exception;


import tt.dz.egobus.api.exception.ResponseException;
import tt.dz.egobus.bean.CodeStatus;

/**
 * WEB全局统一的运行异常处理
 */
public class BusinessException extends ResponseException implements CodeStatus {

    private final CodeStatus codeStatus;

    public BusinessException(CodeStatus codeStatus) {
        this(codeStatus, "[code:" + codeStatus.getCode() + "]:[" + codeStatus.getMsg() + "]");
    }

    public BusinessException(CodeStatus codeStatus, String message) {
        this(codeStatus, message, null);
    }

    public BusinessException(CodeStatus codeStatus, String message, Throwable cause) {
        super(codeStatus, message, cause);
        this.codeStatus = codeStatus;
    }


    @Override
    public int getCode() {
        return this.codeStatus.getCode();
    }

    @Override
    public String getMsg() {
        return this.codeStatus.getMsg();
    }
}
